%%{init: {'themeVariables': { 'fontSize': '12px'}}}%%
graph TD
    classDef path fill:#eee,stroke:#000,color:#000
    classDef plan fill:#fff,stroke-width:1px,color:#000
    classDef itemplan fill:#fff,stroke-width:2px,color:#000
    classDef unbatchedplan fill:#dff,stroke-width:1px,color:#000
    classDef sideeffectplan fill:#fcc,stroke-width:2px,color:#000
    classDef bucket fill:#f6f6f6,color:#000,stroke-width:2px,text-align:left

    subgraph "Buckets for queries/conditions/condition-featured-messages-minimal"
    Bucket0("Bucket 0 (root)<br /><br />1: <br />ᐳ: 9, 10, 38, 39, 40, 41, 11, 13, 18, 26, 30<br />2: PgSelect[8]<br />3: PgSelectRows[14]"):::bucket
    Bucket1("Bucket 1 (listItem)<br />Deps: 11, 40, 26, 30<br /><br />ROOT __Item{1}ᐸ14ᐳ[15]"):::bucket
    Bucket2("Bucket 2 (nullableBoundary)<br />Deps: 16, 11, 40, 26, 30<br /><br />ROOT PgSelectSingle{1}ᐸforumsᐳ[16]<br />1: <br />ᐳ: 20, 27<br />2: PgSelect[21]<br />3: Connection[25]"):::bucket
    Bucket3("Bucket 3 (nullableBoundary)<br />Deps: 25, 11, 20, 40, 26, 27, 30<br /><br />ROOT Connection{2}ᐸ21ᐳ[25]<br />1: PgSelect[32]<br />ᐳ: PageInfo[31], Access[37]<br />2: PgSelectRows[34]<br />ᐳ: 33, 35, 36"):::bucket
    end
    Bucket0 --> Bucket1
    Bucket1 --> Bucket2
    Bucket2 --> Bucket3

    %% plan dependencies
    PgSelect8[["PgSelect[8∈0] ➊<br />ᐸforumsᐳ<br />More deps:<br />- Object[11]"]]:::plan
    Lambda13{{"Lambda[13∈0] ➊<br />ᐸincludeArchivedConditionᐳ<br />More deps:<br />- Constantᐸ[ undefined, 'INHERIT' ]ᐳ[38]"}}:::plan
    Lambda13 --> PgSelect8
    Object11{{"Object[11∈0] ➊<br />ᐸ{pgSettings,withPgClient}ᐳ<br />Dependents: 3"}}:::plan
    Access9{{"Access[9∈0] ➊<br />ᐸ2.pgSettingsᐳ"}}:::plan
    Access10{{"Access[10∈0] ➊<br />ᐸ2.withPgClientᐳ"}}:::plan
    Access9 & Access10 --> Object11
    __Value2["__Value[2∈0] ➊<br />ᐸcontextᐳ"]:::plan
    __Value2 --> Access9
    __Value2 --> Access10
    PgSelectRows14[["PgSelectRows[14∈0] ➊"]]:::plan
    PgSelect8 --> PgSelectRows14
    __InputObject18{{"__InputObject[18∈0] ➊<br />More deps:<br />- Constantᐸtrueᐳ[41]"}}:::plan
    ApplyInput26{{"ApplyInput[26∈0] ➊<br />Dependents: 2"}}:::plan
    __InputObject18 --> ApplyInput26
    Lambda30{{"Lambda[30∈0] ➊<br />ᐸincludeArchivedConditionᐳ<br />Dependents: 2<br />More deps:<br />- Constantᐸ[HIDDEN]ᐳ[39]"}}:::plan
    __Item15[/"__Item[15∈1]<br />ᐸ14ᐳ"\]:::itemplan
    PgSelectRows14 ==> __Item15
    PgSelectSingle16{{"PgSelectSingle[16∈1]<br />ᐸforumsᐳ"}}:::plan
    __Item15 --> PgSelectSingle16
    PgSelect21[["PgSelect[21∈2]<br />ᐸmessages+1ᐳ<br />More deps:<br />- Object[11]<br />- Constantᐸ5ᐳ[40]<br />- ApplyInput[26]<br />- Lambda[30]"]]:::plan
    PgClassExpression20{{"PgClassExpression[20∈2]<br />ᐸ__forums__.”id”ᐳ"}}:::plan
    PgClassExpression27{{"PgClassExpression[27∈2]<br />ᐸ__forums__...chived_at”ᐳ"}}:::plan
    PgClassExpression20 & PgClassExpression27 --> PgSelect21
    Connection25[["Connection[25∈2]<br />ᐸ21ᐳ<br />More deps:<br />- Constantᐸ5ᐳ[40]"]]:::plan
    PgSelect21 --> Connection25
    PgSelectSingle16 --> PgClassExpression20
    PgSelectSingle16 --> PgClassExpression27
    PgSelect32[["PgSelect[32∈3]<br />ᐸmessages(aggregate)ᐳ<br />More deps:<br />- Object[11]<br />- Constantᐸ5ᐳ[40]<br />- ApplyInput[26]<br />- Lambda[30]"]]:::plan
    PgClassExpression20 & PgClassExpression27 --> PgSelect32
    PageInfo31{{"PageInfo[31∈3]"}}:::plan
    Connection25 --> PageInfo31
    First33{{"First[33∈3]"}}:::plan
    PgSelectRows34[["PgSelectRows[34∈3]"]]:::plan
    PgSelectRows34 --> First33
    PgSelect32 --> PgSelectRows34
    PgSelectSingle35{{"PgSelectSingle[35∈3]<br />ᐸmessagesᐳ"}}:::plan
    First33 --> PgSelectSingle35
    PgClassExpression36{{"PgClassExpression[36∈3]<br />ᐸcount(*)ᐳ"}}:::plan
    PgSelectSingle35 --> PgClassExpression36
    Access37{{"Access[37∈3]<br />ᐸ25.hasNextPageᐳ"}}:::plan
    PageInfo31 o--o Access37

    %% define steps
    classDef bucket0 stroke:#696969
    class Bucket0,__Value2,PgSelect8,Access9,Access10,Object11,Lambda13,PgSelectRows14,__InputObject18,ApplyInput26,Lambda30 bucket0
    classDef bucket1 stroke:#00bfff
    class Bucket1,__Item15,PgSelectSingle16 bucket1
    classDef bucket2 stroke:#7f007f
    class Bucket2,PgClassExpression20,PgSelect21,Connection25,PgClassExpression27 bucket2
    classDef bucket3 stroke:#ffa500
    class Bucket3,PageInfo31,PgSelect32,First33,PgSelectRows34,PgSelectSingle35,PgClassExpression36,Access37 bucket3

